import { Entity, PrimaryGeneratedColumn, Column, Index } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

/**
 * 每日挖宝计数与可用铲子次数（按角色+日期维度）
 * remainShovel：可探穴次数（购买累计），usedTimes：当日已挖次数（<=300）
 */
@Entity("tomb_daily_counter")
@ManualTimestamp()
@Index(["characterId", "dateStr"], { unique: true })
export class TombDailyCounterEntity {
  @PrimaryGeneratedColumn({ type: "int", comment: "主键ID" })
  id!: number;

  @Column({ type: "int", name: "character_id", comment: "角色ID" })
  characterId!: number;

  @Column({
    type: "varchar",
    length: 10,
    name: "date_str",
    comment: "日期yyyy-MM-dd",
  })
  dateStr!: string;

  @Column({
    type: "int",
    name: "used_times",
    default: 0,
    comment: "当日已挖次数",
  })
  usedTimes!: number;

  @Column({
    type: "int",
    name: "remain_shovel",
    default: 0,
    comment: "当日剩余可探穴次数（购买累计）",
  })
  remainShovel!: number;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", {
    name: "updated_at",
    nullable: true,
    comment: "更新时间",
  })
  updated_at!: Date | null;
}
